﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Forms.Integration;
using System.Windows.Forms;


namespace PeerON_WPF
{
    /// <summary>
    /// Логика взаимодействия для MainWindow.xaml
    /// </summary>
    /// 
    
    public partial class MainWindow : Window
    {
        bool selectInTextboxFind = true;
        int select_menu_button = 0;
        
        public MainWindow()
        {
            InitializeComponent();
            this.Visibility = Visibility.Hidden;
            var LoadPeerOn = new LoadPeerOn();
            LoadPeerOn.Show();
            System.Threading.Thread.Sleep(2000);
            this.Visibility = Visibility.Visible;
            LoadPeerOn.Close();
            button_media_activ();
            select_menu_button = 1;
            this.webBrowser.Navigate("http://free.ranetka.ru/");
            this.webBrowser.Visibility = Visibility.Visible;
            this.textBlockChat.Visibility = Visibility.Hidden;
            this.listBoxHubs.Visibility = Visibility.Hidden;
        }
        
//методы загружающие картинки (оптимизация кода)-----------------------------------------------------------------------------------------
        private void button_media()
        {
            Uri uri = new Uri("pack://application:,,,/PeerON_WPF;component/Images/button_media.png");
            BitmapImage bitmap = new BitmapImage(uri);
            this.buttonMedia.Source = bitmap;
        }

        private void button_media_activ()
        {
            Uri uri = new Uri("pack://application:,,,/PeerON_WPF;component/Images/button_media_active.png");
            BitmapImage bitmap = new BitmapImage(uri);
            this.buttonMedia.Source = bitmap;
        }

        private void button_search()
        {
            Uri uri = new Uri("pack://application:,,,/PeerON_WPF;component/Images/button_search.png");
            BitmapImage bitmap = new BitmapImage(uri);
            this.buttonSearch.Source = bitmap;
        }

        private void button_search_activ()
        {
            Uri uri = new Uri("pack://application:,,,/PeerON_WPF;component/Images/button_search_active.png");
            BitmapImage bitmap = new BitmapImage(uri);
            this.buttonSearch.Source = bitmap;
        }

        private void button_uploads()
        {
            Uri uri = new Uri("pack://application:,,,/PeerON_WPF;component/Images/button_uploads.png");
            BitmapImage bitmap = new BitmapImage(uri);
            this.buttonUploads.Source = bitmap;
        }

        private void button_uploads_activ()
        {
            Uri uri = new Uri("pack://application:,,,/PeerON_WPF;component/Images/button_uploads_active.png");
            BitmapImage bitmap = new BitmapImage(uri);
            this.buttonUploads.Source = bitmap;
        }

        private void button_chat()
        {
            Uri uri = new Uri("pack://application:,,,/PeerON_WPF;component/Images/button_chat.png");
            BitmapImage bitmap = new BitmapImage(uri);
            this.buttonChat.Source = bitmap;
        }

        private void button_chat_activ()
        {
            Uri uri = new Uri("pack://application:,,,/PeerON_WPF;component/Images/button_chat_active.png");
            BitmapImage bitmap = new BitmapImage(uri);
            this.buttonChat.Source = bitmap;
        }

        private void button_hubs()
        {
            Uri uri = new Uri("pack://application:,,,/PeerON_WPF;component/Images/button_hubs.png");
            BitmapImage bitmap = new BitmapImage(uri);
            this.buttonHubs.Source = bitmap;
        }

        private void button_hubs_activ()
        {
            Uri uri = new Uri("pack://application:,,,/PeerON_WPF;component/Images/button_Hubs_active.png");
            BitmapImage bitmap = new BitmapImage(uri);
            this.buttonHubs.Source = bitmap;
        }

//-------------------------------------------------------------------------------------------------------------------------------------------
        private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.DragMove();
        }
      
        private void buttonExit_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void buttonMinimized_Click(object sender, RoutedEventArgs e)
        {
            this.WindowState = WindowState.Minimized;
        }     

//логика поиска------------------------------------------------------------------------------------------------------------------
        private void buttonFind_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.MessageBox.Show("Поиск не дал результата!");
        }
     
//действия при наведении на кнопку меню----------------------------------------------------------------------------
        private void buttonMedia_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Uri uri = new Uri("pack://application:,,,/PeerON_WPF;component/Images/button_media_hover.png");
            BitmapImage bitmap = new BitmapImage(uri);
            this.buttonMedia.Source = bitmap;
        }

        private void buttonSearch_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Uri uri = new Uri("pack://application:,,,/PeerON_WPF;component/Images/button_search_hover.png");
            BitmapImage bitmap = new BitmapImage(uri);
            this.buttonSearch.Source = bitmap;
        }

        private void buttonUploads_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Uri uri = new Uri("pack://application:,,,/PeerON_WPF;component/Images/button_uploads_hover.png");
            BitmapImage bitmap = new BitmapImage(uri);
            this.buttonUploads.Source = bitmap;
        }

        private void buttonChat_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Uri uri = new Uri("pack://application:,,,/PeerON_WPF;component/Images/button_chat_hover.png");
            BitmapImage bitmap = new BitmapImage(uri);
            this.buttonChat.Source = bitmap;
        }

        private void buttonHubs_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Uri uri = new Uri("pack://application:,,,/PeerON_WPF;component/Images/button_Hubs_hover.png");
            BitmapImage bitmap = new BitmapImage(uri);
            this.buttonHubs.Source = bitmap;
        }

//действия при уходе с кнопки меню (возврат кнопки в исходное положение)--------------------------------------------------------
        private void buttonMedia_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            if (select_menu_button == 1)
            {
                button_media_activ();
            } 
            else
            {
                button_media();
            }            
        }

        private void buttonSearch_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            if (select_menu_button == 2)
            {
                button_search_activ();
            }
            else
            {
                button_search();
            } 
        }

        private void buttonUploads_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            if (select_menu_button == 3)
            {
                button_uploads_activ();
            }
            else
            {
                button_uploads();
            } 
        }

        private void buttonChat_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            if (select_menu_button == 4)
            {
                button_chat_activ();
            }
            else
            {
                button_chat();
            } 
        }

        private void buttonHubs_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            if (select_menu_button == 5)
            {
                button_hubs_activ();
            }
            else
            {
                button_hubs();
            } 
        }

// действия по нажатия на кнопки меню -------------------------------------------------------------------------------------------
        private void buttonMedia_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.webBrowser.Navigate("http://free.ranetka.ru/");
            this.webBrowser.Visibility = Visibility.Visible;
            this.listBoxHubs.Visibility = Visibility.Hidden;
            this.textBlockChat.Visibility = Visibility.Hidden;
            button_media_activ();
            button_search();
            button_uploads();
            button_chat();
            button_hubs();
            select_menu_button = 1;
        }        

        private void buttonSearch_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.webBrowser.Navigate("http://80.255.139.136/");
            this.webBrowser.Visibility = Visibility.Visible;
            this.listBoxHubs.Visibility = Visibility.Hidden;
            this.textBlockChat.Visibility = Visibility.Hidden;
            button_media();
            button_search_activ();
            button_uploads();
            button_chat();
            button_hubs();
            select_menu_button = 2;
        }

        private void buttonUploads_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.textBlockChat.Text = "Это будут раздачи...";
            this.textBlockChat.Visibility = Visibility.Visible;
            this.webBrowser.Visibility = Visibility.Hidden;
            this.listBoxHubs.Visibility = Visibility.Hidden;
            button_media();
            button_search();
            button_uploads_activ();
            button_chat();
            button_hubs();
            select_menu_button = 3;
        }

        private void buttonChat_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.textBlockChat.Text = "Это будет чат...";
            this.textBlockChat.Visibility = Visibility.Visible;
            this.webBrowser.Visibility = Visibility.Hidden;
            this.listBoxHubs.Visibility = Visibility.Hidden;
            button_media();
            button_search();
            button_uploads();
            button_chat_activ();
            button_hubs();
            select_menu_button = 4;
        }       

        private void buttonHubs_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.textBlockChat.Visibility = Visibility.Hidden;
            this.webBrowser.Visibility = Visibility.Hidden;
            this.listBoxHubs.Visibility = Visibility.Visible;
            button_media();
            button_search();
            button_uploads();
            button_chat();
            button_hubs_activ();
            select_menu_button = 5;
        }
    }
}
